/**
 * Copyright 2018-2020 victor & highset (http://www.highset.cn)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.highset.modules.base.factory;

import cn.highset.common.utils.JPinYinUtil;
import cn.highset.modules.base.entity.Exhibitor;
import cn.hutool.core.util.StrUtil;

import java.util.Date;

/**
 * 展商创建工厂
 */
public class ExhibitorFactory {


    /**
     * 展商修改
     */
    public static Exhibitor edit(Exhibitor newBean, Exhibitor oldBean) {
        if (newBean == null || oldBean == null) {
            return oldBean;
        } else {
            oldBean.setCompanyName(newBean.getCompanyName());
            oldBean.setCompanyNameEn(newBean.getCompanyNameEn());

            String companyNamePy = StrUtil.trimToEmpty(JPinYinUtil.changeToTonePinYin(newBean.getCompanyName()));
            oldBean.setCompanyNamePy(companyNamePy.substring(0,Math.min(150,companyNamePy.length())));

            String companyNameEnPy = StrUtil.trimToEmpty(JPinYinUtil.changeToTonePinYin(newBean.getCompanyNameEn()));
            oldBean.setCompanyNameEnPy(companyNameEnPy.substring(0,Math.min(150,companyNameEnPy.length())));

            oldBean.setStandNo(newBean.getStandNo());
            oldBean.setUpdateTime(new Date());
            return oldBean;
        }
    }

}
